package nc.ui.vvtbb.tool;

import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.busibean.ISysInitQry;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.ui.pub.ClientEnvironment;
import nc.vo.pub.BusinessException;

public class TbbUtil {
	
	public static boolean isShowPkCorp(){
		boolean  is= false;
		try {
			ISysInitQry iSysInitQry = NCLocator.getInstance().lookup(
					ISysInitQry.class);
			String pkCorp = ClientEnvironment.getInstance().getCorporation()
					.getPrimaryKey();
			is = iSysInitQry.getParaBoolean(pkCorp, "CMP56").booleanValue();
		} catch (Exception e) {
		}
		return is;
	}
	
	public static  boolean checkRole() throws BusinessException{
		
		String sql = "select count(1) from SM_USER_ROLe,SM_ROLE where SM_USER_ROLE.PK_ROLE = SM_ROLE.PK_ROLE"
			         +" and SM_USER_ROLE.CUSERID='"+ClientEnvironment.getInstance().getUser().getPrimaryKey()+"' and ROLE_CODE='VV_TB_CORP_ROLE'";
		IUAPQueryBS query = NCLocator.getInstance().lookup(IUAPQueryBS.class);
		Object obj = query.executeQuery(sql, new ColumnProcessor());
		return  ((Integer)obj).intValue()>0?true:false;
	}
	public static String getDept() throws BusinessException{
		String sql = "select BD_PSNDOC.PK_DEPTDOC from SM_USERANDCLERK,BD_PSNBASDOC, BD_PSNDOC where SM_USERANDCLERK.PK_PSNDOC = BD_PSNBASDOC.PK_PSNBASDOC" +
				" and BD_PSNDOC.PK_PSNBASDOC = BD_PSNBASDOC.PK_PSNBASDOC and SM_USERANDCLERK.USERID='"+
				ClientEnvironment.getInstance().getUser().getPrimaryKey()+"'";
        IUAPQueryBS query = NCLocator.getInstance().lookup(IUAPQueryBS.class);
        Object obj = query.executeQuery(sql, new ColumnProcessor());
        return obj == null ? null : (String) obj;
	}

}
